package me.yuxiaoyao.lock;

import java.util.concurrent.TimeUnit;

/**
 * @author kerryzhang on 20/12/23
 */

public interface Lock extends java.util.concurrent.locks.Lock {

    /**
     * block lock
     *
     * @param time
     * @param unit
     * @throws IllegalStateException
     * @throws InterruptedException
     */
    default void lock(long time, TimeUnit unit) throws IllegalStateException, InterruptedException {
        boolean b = this.tryLock(time, unit);
        if (!b) {
            throw new IllegalStateException();
        }
    }

}
